package mmpathgen.util;

import soot.SootMethod;
import soot.jimple.toolkits.annotation.purity.SootMethodFilter;

public class JRELibFilter implements SootMethodFilter {

	static private final String[] jre_lib_pfx_full = { "com.sun",
			"java.applet", "java.awt", "java.beans", "java.io", "java.lang",
			"java.math", "java.net", "java.nio", "java.rmi", "java.security",
			"java.sql", "java.text", "java.util", "javax", "org.ietf.jgss",
			"org.jcp", "org.omg", "org.w3c.dom", "org.xml.sax", "sun.applet",
			"sun.audio", "sun.awt", "sun.beans", "sun.corba", "sun.dc",
			"sun.font", "sun.instrument", "sun.io", "sun.java2d", "sun.jdbc",
			"sun.jkernel", "sun.management", "sun.misc", "sun.net", "sun.nio",
			"sun.org.mozilla.javascript.internal", "sun.print", "sun.reflect",
			"sun.rmi", "sun.security", "sun.swing", "sun.text", "sun.tools",
			"sun.util", "sunw.io", "sunw.util" };

	static private final String[] jre_lib_pfx_simp = { "java", "javax",
			"org.ietf", "org.omg", "org.w3c", "org.xml", };

	public boolean want(SootMethod method) {

		String c = method.getDeclaringClass().toString();

		String[] jre_lib_pfx = jre_lib_pfx_full;
		// String[] jre_lib_pfx = jre_lib_pfx_simp;
		for (int i = 0; i < jre_lib_pfx.length; i++)
			if (c.startsWith(jre_lib_pfx[i]))
				return false;

		return true;

	}
}
